#!/bin/sh

if [ "$os" = "centos" ]
then
        echo "mariadb soft nproc 1024000" >> /etc/security/limits.conf
        echo "mariadb hard nproc 1024000" >> /etc/security/limits.conf
        echo "mariadb soft nofile 1024000" >> /etc/security/limits.conf
        echo "mariadb hard nofile 1024000" >> /etc/security/limits.conf
        sed -i 's/4096/1024000/g' /etc/security/limits.d/20-nproc.conf
        echo "DefaultLimitNOFILE=1024000" >> /etc/systemd/system.conf
        echo "DefaultLimitNPROC=1024000" >> /etc/systemd/system.conf
        if [ -d /etc/systemd/system/mariadb.service.d ]
        then
                echo "/etc/systemd/system/mariadb.service.d is existed!"
        else
                mkdir -p /etc/systemd/system/mariadb.service.d
        fi
        echo "[Service]" > /etc/systemd/system/mariadb.service.d/zgs.conf
        echo "LimitNOFILE=65535" >> /etc/systemd/system/mariadb.service.d/zgs.conf
        echo "LimitNPROC=65535" >> /etc/systemd/system/mariadb.service.d/zgs.conf
        #echo "LimitNOFILE=1024000" >> /usr/lib/systemd/system/mariadb.service
        #echo "LimitNPROC=1024000" >> /usr/lib/systemd/system/mariadb.service
fi

